package main


import "io/ioutil"
import "state"
import "fmt"
import "api"


func main() {

	data, err := ioutil.ReadFile("test.luac")

	if err != nil {
		panic(err)
	}

	ls := state.New()

	ls.Load(data, "max", "b")

	ls.Call(0, 0)
}

func printStack(ls api.LuaState) {

	top := ls.GetTop()

	for i := 1; i <= top; i++ {

		t := ls.Type(i)
		switch t {
			case api.LUA_TBOOLEAN: 	fmt.Printf("[%t]", ls.ToBoolean(i))

			case api.LUA_TNUMBER:	fmt.Printf("[%g]", ls.ToNumber(i))

			case api.LUA_TSTRING:	fmt.Printf("[%q]", ls.ToString(i))

			default:				fmt.Printf("[%s]", ls.TypeName(t))
		}
	}

	fmt.Printf("\n")
}